#include<string>
class Solution {
public:
    int hash[129] = { 0 };
    int lengthOfLongestSubstring(std::string s) {
        if (s.size() == 1)
            return 1;
        int ret = 0, count = 0;
        int left = 0, right = 0;
        for (; right < s.size(); right++) {

            int n = s[right];
            hash[n]++;

            while (hash[n] > 1)
                hash[s[left++]]--;
            ret = max(ret, right - left + 1);
        }

        return ret;
    }
};